package com.zhilianbao.leyaogo.ui.adapter.shoppingcart;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.bql.baseadapter.recycleView.QuickRcvAdapter;
import com.bql.baseadapter.recycleView.QuickRcvHolder;
import com.zhilianbao.leyaogo.R;
import com.zhilianbao.leyaogo.model.response.shoppingcart.ShoppingCartGood;
import com.zhilianbao.leyaogo.utils.ImageUtils;
import com.zhilianbao.leyaogo.utils.Utils;
import com.zhilianbao.leyaogo.view.widgets.MoneyTextView;

import java.util.List;

/**
 * Author: hcy
 * Description:填写订单，去支付Adapter
 * Created: 2016/10/24 16:13
 */
public class PayOrderGoodsAdapter extends QuickRcvAdapter<ShoppingCartGood> {
    public PayOrderGoodsAdapter(Context context, List<ShoppingCartGood> data) {
        super(context, data, R.layout.item_pay_order);
    }


    @Override
    protected void bindDataHelper(QuickRcvHolder viewHolder, int position, ShoppingCartGood item) {
        viewHolder.setText(R.id.tv_title, item.getGoodsName()).setText(R.id.tv_sub_title, item.getGoodsDesc()).setText(R.id.tv_count, "X " + item.getNumber());
        MoneyTextView mtv = viewHolder.getView(R.id.tv_sale_price);
        mtv.setAmount(/*item.getActivityType() == 1 || item.getActivityType() == 2 ? item.getDiscountPrice() :*/ Utils.getGoodPrice(item));
        ImageView iv = viewHolder.getView(R.id.iv_goods_img);
        ImageUtils.loadGoodsPic(Utils.returnUrlShow(item.getGoodsPic()), iv);
        if (position == mList.size() - 1) {
            viewHolder.getView(R.id.line).setVisibility(View.GONE);
        } else {
            viewHolder.getView(R.id.line).setVisibility(View.VISIBLE);
        }
    }
}
